/*******************************************************************************
 * Copyright:   Copyright (c) 2007. Hisilicon Technologies, CO., LTD.
 * Version:     V300R001B01
 * Filename:    KeypadMdd.h
 * Description: This module provides a stream interface for the I2C bus driver.
 * History:
                1.Created by SunShaojie on 2008/11/28
*******************************************************************************/

DWORD KPD_Init(LPCTSTR pContext, DWORD dwBusContext);
BOOL KPD_Deinit(DWORD hDeviceContext);
DWORD KPD_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode);
BOOL KPD_Close(DWORD hOpenContext);
VOID KPD_PowerDown(DWORD hDeviceContext);
VOID KPD_PowerUp(DWORD hDeviceContext);
BOOL KPD_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn,
                   DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut,
                   PDWORD pdwActualOut);

//-----------------------------------------------------------------------------
//
// Function: EstablishVkToScTable
//
// This function establish the scan-code table according Virual-code table.
//
VOID EstablishVkToScTable(VOID);

//-----------------------------------------------------------------------------
//
// Function: VirtualKeyRemap
//
// This function remaps multiple virtual key or long pressed virtual key to
// final virtual key.
//
static VOID VirtualKeyRemap(PKEYPAD_REMAP_STATE pRemapState, DWORD adwVkNewState[], DWORD dwTime, BOOL *bKeyPoll);

//-----------------------------------------------------------------------------
//
// Function: VirtualPressedReleasedKeys
//
// This function finds virtual pressed or released by comparing old and new state.
//
static VOID VirtualPressedReleasedKeys(const DWORD adwVkState[], const DWORD adwVkNewState[]);

//-----------------------------------------------------------------------------
//
// Function: VirtualKeyAutoRepeat
//
// This function sends key pressed events for auto-repeat keys.
//
static VOID VirtualKeyAutoRepeat(const PKEYPAD_DEVICE pDevice, PKEYPAD_REPEAT_STATE pRepeatState, const DWORD adwVkNewState[], DWORD dwTime, BOOL *pbKeyPoll);

//-----------------------------------------------------------------------------
//
// Function: KppIsrThreadProc
//
// This function start a thread for keypad interrupt.
//
DWORD KppIsrThreadProc(VOID *pContext);

//-----------------------------------------------------------------------------
//
// Function: KppCntlThreadProc
//
// This function initialize the keypad control event.
//
DWORD KppCntlThreadProc(VOID *pContext);

//-----------------------------------------------------------------------------
//
// Function: KppBklThreadProc
//
// This function initialize the keypad Backlight light event.
//
DWORD KppBklThreadProc(VOID *pContext);
